<%@include file="/common/taglibs.jsp" %>
<html>
<head>
<%@include file="/common/scripts.jsp" %>
<script type="text/javascript">
<!--
$(function(){
	$("#theForm").validate({rules: {
	    username : {
	        required : true,
	        minlength: 4
	    },
	    displayName : {
	        required : true,
	    },
	    email : {
	        required : true,
	        email : true
	    }
	}});
	
	$("#saveBtn").click(function(){
		$('#theForm').ajaxSubmit({
			url:"save",
			beforeSubmit:function(){
				var rtnVal = $("#theForm").valid();
				return rtnVal;
			},
			success:function(data, statusText, xhr, $form){
				alert(data.message);
				if (data.success) {
					var url = "edit?id="+data.data;
					window.location.href = url;
				}
			},
			dataType:'json'
		});
	});
});	
//-->
</script>
</head>
<body>
    <div class="pageOuter">
        <!--body content-->
        <div class="contentOuter">
            <div class="pageTitle">
                <fmt:message key='menu.manage.user' />
            </div>
            <div class="buttonBox_R">
                   <a href="javascript:void(0);" id="saveBtn" class="css_btn"><img class="button save" src="<c:url value='/images/icon_transparent.png'/>" />
                    <fmt:message key='button.save' /></a>
                <a href="<c:url value='back'/>" class="css_btn"><img class="button back" src="<c:url value='/images/icon_transparent.png'/>" />
                <fmt:message key='button.back.page' /></a>
            </div>

            <div class="blockBorder">
                <form:form name="theForm" id="theForm" action="save" method="post" commandName="sysUser">
                    <form:hidden path="id" />
                    <table class="queryForm">
                        <tr>
                            <td width="15%"><span class="required">*</span>
                            <fmt:message key='system.bo.SysUser' />:</td>
                            <td><c:choose>
                                    <c:when test="${sysUser.id == null }">
                                        <form:input path="username" maxlength="20" cssClass="required" cssStyle="width: 70%;" />
                                    </c:when>
                                    <c:otherwise>${sysUser.username }</c:otherwise>
                                </c:choose></td>
                        </tr>
                        <tr>
                            <td width="15%"><span class="required">*</span>
                            <fmt:message key='system.bo.SysUser.name' />:</td>
                            <td><form:input path="displayName" maxlength="100"  cssClass="required" cssStyle="width: 70%;" /></td>
                        </tr>
                        <tr>
                            <td width="15%"><span class="required">*</span>
                            <fmt:message key='system.bo.SysUser.email' />:</td>
                            <td><form:input path="email" maxlength="100"  cssClass="required email" cssStyle="width: 70%;" /></td>
                        </tr>
                        <c:if test="${sysUser.isSupervisor != true }">
                        <tr>
                            <td width="15%"><span class="required">*</span>
                            <fmt:message key='system.bo.SysUser.enable' />:</td>
                            <td><form:radiobutton path="enable" value="true"/><fmt:message key='system.bo.SysUser.enable.true' />
                            <form:radiobutton path="enable" value="false"/><fmt:message key='system.bo.SysUser.enable.false' /></td>
                        </tr>
                        </c:if>
                    </table>
                </form:form>
            </div>


        </div>
    </div>
</body>
<!--pageOuter end-->
</html>
